/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1650088188523_8991';

  // add your middleware config here
  config.middleware = [];

  // 安全防范
  config.security = {
    // 关闭 csrf 攻击验证
    csrf: {
      enable: false,
    },
  };

  // 数据库相关配置
  config.sequelize = {
    dialect: 'mysql',
    host: '127.0.0.1',
    port: '3306',
    user: 'root',
    password: '123456',
    database: 'q_admin_new',
    // 打印sql
    logging: true,
    // 北京时间
    timezone: '+08:00',
    // 日期格式化
    dialectOptions: {
      dateStrings: true,
      typeCast(field, next) {
        if (field.type === 'DATETIME') {
          return field.string();
        }
        return next();
      },
    },
    define: {
      // 关闭 timestamps
      timestamps: false,
      // 自定义表名
      freezeTableName: true,
    },
  };

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  return {
    ...config,
    ...userConfig,
  };
};
